create or replace view vac_page_rpt_cols as
with rc as
(
 select workspace,
    application_id,
    application_name,
    page_id,
    page_name,
    region_name,
    column_alias,
    display_as,
    display_as_code,
    to_char(display_sequence) display_sequence,
    heading,
    format_mask,
    html_expression,
    css_class,
    css_style,
    highlight_words,
    column_link_url,
    column_link_text,
    column_link_attributes,
    page_checksum,
    column_alignment,
    heading_alignment,
    to_char(default_sort_sequence) default_sort_sequence,
    default_sort_direction,
    sortable_column,
    sum_column,
    column_is_hidden,
    condition_type,
    condition_expression1,
    condition_expression2,
    named_list_of_values,
    inline_list_of_values,
    lov_show_nulls,
    lov_display_extra_values,
    lov_null_text,
    lov_null_value,
    to_char(form_element_width) form_element_width,
    to_char(form_element_height) form_element_height,
    form_element_attributes,
    form_element_option_attributes,
    is_required,
    standard_validations,
    attribute_01,
    attribute_02,
    attribute_03,
    attribute_04,
    attribute_05,
    attribute_06,
    attribute_07,
    attribute_08,
    attribute_09,
    attribute_10,
    primary_key_column_source_type,
    ac_utils.hs(primary_key_column_source) primary_key_column_source_hs,
    dbms_lob.substr(primary_key_column_source,4000, 1)        primary_key_column_source_sr1,
    dbms_lob.substr(primary_key_column_source,4000, 4000+1 )  primary_key_column_source_sr2,
    dbms_lob.substr(primary_key_column_source,4000, 8000+1 )  primary_key_column_source_sr3,
    dbms_lob.substr(primary_key_column_source,4000, 12000+1)  primary_key_column_source_sr4,
    derived_column,
    column_default,
    column_default_type,
    reference_schema,
    reference_table_name,
    reference_column_name,
    authorization_scheme,
    authorization_scheme_id,
    include_in_export,
    print_column_width,
    print_column_alignment,
    region_id,
    region_report_column_id,
    column_comment,
    'APEX_APPLICATION_PAGE_RPT_COLS' src_view_name
 from APEX_APPLICATION_PAGE_RPT_COLS t
)
select
    workspace,
    application_id,
    application_name,
    page_id,
    page_name,
    region_name,
    region_id,
    column_alias,
      to_clob(primary_key_column_source_sr1)||to_clob(primary_key_column_source_sr2)
    ||to_clob(primary_key_column_source_sr3)||to_clob(primary_key_column_source_sr4) primary_key_column_source_sr,
    region_report_column_id,
    u_name,
    u_value,
    src_view_name
from
(
select
    workspace,
    application_id,
    application_name,
    page_id,
    page_name,
    region_name,
    region_id,
    column_alias,
    region_report_column_id,
    primary_key_column_source_sr1,
    primary_key_column_source_sr2,
    primary_key_column_source_sr3,
    primary_key_column_source_sr4,
    u_name,
    u_value,
    src_view_name
from rc
UNPIVOT INCLUDE NULLS ( u_value
   FOR    u_name
   IN
   (
    display_as,
    display_as_code,
    display_sequence,
    heading,
    format_mask,
    html_expression,
    css_class,
    css_style,
    highlight_words,
    column_link_url,
    column_link_text,
    column_link_attributes,
    page_checksum,
    column_alignment,
    heading_alignment,
    default_sort_sequence,
    default_sort_direction,
    sortable_column,
    sum_column,
    column_is_hidden,
    condition_type,
    condition_expression1,
    condition_expression2,
    named_list_of_values,
    inline_list_of_values,
    lov_show_nulls,
    lov_display_extra_values,
    lov_null_text,
    lov_null_value,
    form_element_width,
    form_element_height,
    form_element_attributes,
    form_element_option_attributes,
    is_required,
    standard_validations,
    attribute_01,
    attribute_02,
    attribute_03,
    attribute_04,
    attribute_05,
    attribute_06,
    attribute_07,
    attribute_08,
    attribute_09,
    attribute_10,
    primary_key_column_source_type,
    primary_key_column_source_hs,
    derived_column,
    column_default,
    column_default_type,
    reference_schema,
    reference_table_name,
    reference_column_name,
    authorization_scheme,
    authorization_scheme_id,
    include_in_export,
    print_column_width,
    print_column_alignment,
    column_comment
   )
 )
);

